from PySide6.QtWidgets import (QPushButton, QLabel, QVBoxLayout, QWidget)
from PySide6.QtGui import QPixmap
from PySide6.QtCore import Qt
from src.utils.style_manager import StyleManager

# 从新位置导入按钮组件
from src.views.widgets.buttons import (
    PrimaryButton,
    SuccessButton,
    WarningButton,
    DangerButton,
    InfoButton
)

class ImageButton(QPushButton):
    """自定义图像按钮组件"""
    def __init__(self, image_path, label, size=(80, 80)):
        super().__init__()
        self.setFixedSize(*size)
        
        layout = QVBoxLayout(self)
        layout.setContentsMargins(5, 5, 5, 5)
        
        # 图片
        self.image_label = QLabel()
        self.image_label.setAlignment(Qt.AlignCenter)
        pixmap = QPixmap(image_path)
        self.image_label.setPixmap(pixmap.scaled(size[0]-10, size[1]-30, Qt.KeepAspectRatio, Qt.SmoothTransformation))
        
        # 标签
        self.text_label = QLabel(label)
        self.text_label.setAlignment(Qt.AlignCenter)
        
        layout.addWidget(self.image_label)
        layout.addWidget(self.text_label)